﻿namespace SsisLdapSource.DirectoryServicesProtocolsExtensions
{
    using System;
    using System.Text;

    public delegate object DecodeLdapValue(object value);

    public class LdapAttributeMetaMap
    {
        public LdapAttributeMetaMap(string ldapDisplayName, bool isMultiValued)
        {
            LdapDisplayName = ldapDisplayName;
            IsMultiValued = isMultiValued;
        }

        public Type RawDotNetTypeEquivalent { get; set; }

        public Type SemanticDotNetTypeEquivalent { get; set; }

        public string LdapDisplayName { get; private set; }

        public bool IsMultiValued { get; set; }

        public DecodeLdapValue SemanticValueConversionFunction { get; set; }

        public bool ExpansionMayBeRequired { get; set; }

        public override string ToString()
        {
            var stringBuilder = new StringBuilder();
            stringBuilder.AppendFormat("LdapDisplayName: {0}", LdapDisplayName);
            stringBuilder.AppendFormat("DotNetType {0}", RawDotNetTypeEquivalent);
            stringBuilder.AppendFormat("DotNetSemanticType {0}", SemanticDotNetTypeEquivalent);
            stringBuilder.AppendFormat("IsMultiValued {0}", IsMultiValued);
            return stringBuilder.ToString();
        }
    }
}
